package io.renren.modules.app.controller;

import io.renren.common.utils.R;
import io.renren.common.utils.StringUtil;
import io.renren.modules.app.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/weixin")
@Api("微信相关")
public class WeixinAction {
    @Resource
    UserService userService;

    @GetMapping("getopenid")
    @ApiOperation(value = "获取用户的openid", notes = " 参数:{code :code }")
    public R getopenid(String code) {

        StringUtil.checkParams(code);

        return userService.getopenid(code);
    }

    @GetMapping("getWeixinUserInfo")
    @ApiOperation(value = "获取微信用户信息", notes = " 参数:{openid:openid,accessToken:accessToken}")
    public R getUserInfo(String openid, String accessToken) {

        StringUtil.checkParams(openid, accessToken);

        return userService.getUserInfo(openid, accessToken);
    }

    @GetMapping("getSignature")
    @ApiOperation(value = "获取getSignature", notes = "参数:url")
    public R getSignature(String url) {
        return userService.getSignature(url);

    }
}
